import os

import pandas as pd


def stand_sca(data):
    """
    标准差标准化
    :param data:传入的数据
    :return:标准化之后的数据
    """
    new_data = (data - data.mean()) / data.std()
    return new_data


def softmax(data):
    new_data = data / data.sum()
    return new_data


if __name__ == '__main__':
    # 存储
    features = ['UpdateTime', 'AskPrice1', 'AskPrice2', 'AskPrice3', 'AskPrice4', 'AskPrice5',
                'AskPrice6', 'AskPrice7', 'AskPrice8', 'AskPrice9', 'AskPrice10', 'AskVolume1',
                'AskVolume2', 'AskVolume3', 'AskVolume4', 'AskVolume5',
                'AskVolume6', 'AskVolume7', 'AskVolume8', 'AskVolume9', 'AskVolume10', 'BidPrice1',
                'BidPrice2', 'BidPrice3',
                'BidPrice4', 'BidPrice5', 'BidPrice6',
                'BidPrice7', 'BidPrice8', 'BidPrice9', 'BidPrice10', 'BidVolume1',
                'BidVolume2', 'BidVolume3', 'BidVolume4', 'BidVolume5', 'BidVolume6',
                'BidVolume7', 'BidVolume8', 'BidVolume9', 'BidVolume10', 'Volume', 'LastPrice']
    mic_feature = ['AskPrice1', 'AskPrice2', 'AskPrice3', 'AskPrice4', 'AskPrice5',
                   'AskPrice6', 'AskPrice7', 'AskPrice8', 'AskPrice9', 'AskPrice10', 'AskVolume1',
                   'AskVolume2', 'AskVolume3', 'AskVolume4', 'AskVolume5',
                   'AskVolume6', 'AskVolume7', 'AskVolume8', 'AskVolume9', 'AskVolume10', 'BidPrice1',
                   'BidPrice2', 'BidPrice3',
                   'BidPrice4', 'BidPrice5', 'BidPrice6',
                   'BidPrice7', 'BidPrice8', 'BidPrice9', 'BidPrice10', 'BidVolume1',
                   'BidVolume2', 'BidVolume3', 'BidVolume4', 'BidVolume5', 'BidVolume6',
                   'BidVolume7', 'BidVolume8', 'BidVolume9', 'BidVolume10']
    # print(df_all.head())
    # df = pd.read_csv('2021-1-4.csv')
    # # df['OT'] = df['Volume']
    # # df = df.drop(labels=['Volume'], axis=1)
    # # columns = df.columns.tolist()
    # print(np.sort(np.asarray(columns)))
    # df_all = pd.concat([df_all, df])
    df_all = pd.DataFrame(columns=features)
    cnt = 0
    sum = 0
    for root, dirs, files in os.walk(r"../data_mid"):
        for file in files:
            cnt += 1
            # 获取文件所属目录
            # print(root)
            # 获取文件路径
            path = os.path.join(root, file)
            print(file[:file.index('.')])
            df = pd.read_csv(path)
            df = df[features]
            # df['Volume'] = softmax(df['Volume'])
            # print(df['UpdateTime'])
            df['UpdateTime'] = file[:file.index('.')] + ' ' + df['UpdateTime']
            print(df['UpdateTime'])
            sum += len(df)
            print(len(df))
            df_all = pd.concat([df_all, df])
    print(cnt)
    print(sum)
    df_all.to_csv('mid.csv')
    # cnt = 0
    # for root, dirs, files in os.walk(r"data"):
    #     for file in files:
    #         cnt += 1
    #         # 获取文件所属目录
    #         # print(root)
    #         # 获取文件路径
    #         # path = os.path.join(root, file)
    #         # df = pd.read_csv(path)
    #         # df = df[features]
    #         # df_all = pd.concat([df_all, df])
    # print(cnt * 1201)
